var costRules = new Object;
var indentPrice = new Number(0);
var realIndentPrice = new Number(0);
var isNeedTakingGoods = new Number(0);
var fakeIndentID = 0;// 一个假的indentID
var initialAddProductCurtainForm = document.getElementById(
		'addProductCurtainForm-0').cloneNode(true);
var initialAddClothCurtainClothSizeForm = document.getElementById(
		'addClothCurtainClothSizeForm-0').cloneNode(true);
var initialAddClothCurtainYarnSizeForm = document.getElementById(
		'addClothCurtainYarnSizeForm-0').cloneNode(true);
var uploadGoodTypeStatus = 0;
// 布艺帘布尺寸是否填写
var isClothSizeInput = false;
// 布艺帘纱尺寸是否填写
var isYarnSizeInput = false;
// 布艺帘头尺寸是否填写
var isHeadSizeInput = false;
// 成品帘尺寸是否填写
var isProductSizeInput = false;
// 正在填写一个布艺帘布尺寸
var isCurrentClothSizeInput = false;
// 正在填写一个布艺帘纱尺寸
var isCurrentYarnSizeInput = false;
// 正在填写一个布艺帘帘头尺寸
var isCurrentHeadSizeInput = false;


$(function() {
	initialCurrentPage();
	$(".custom-deleteAddCurtainForm").hide();
	$(".custom-newAddCurtainForm").hide();
});
// 更改纱帘和布帘的配件
function changeClothCurtainAccessoriesType(object) {
	// 如果选择了单层布或者单层纱的话
	if ($("input[name='structure']:checked").val() == 0
			|| $("input[name='structure']:checked").val() == 1) {
		// 如果选择了打孔款
		if ($("input[name='style']:checked").val() == 0) {
			if ($(object).val() == '罗马杆') {
				$(object).parent().parent().parent().parent().next().show();
			} else {
				toastr.warning("打孔款只能选择罗马杆");
				$(object).parent().parent().parent().next().hide();
				$(object).removeAttr("checked");
			}
		}
		// 如果选择了韩褶或插钩款
		else if ($("input[name='style']:checked").val() == 3) {
			if ($(object).val() == '罗马杆') {
				$(object).parent().parent().parent().parent().next().show();
			} else {
				$(object).parent().parent().parent().parent().next().hide();

			}
		}
		// 如果选择了帘头款
		else if ($("input[name='style']:checked").val() == 4) {
			if ($(object).val() == '罗马杆') {
				toastr.warning("帘头款不能选择罗马杆");
				$(object).removeAttr("checked");
			}
		}
	} else { // 如果选择了布纱双层
		// 如果选择了打孔款
		if ($("input[name='style']:checked").val() == 0) {
			// 如果是正在填写布
			if (isCurrentClothSizeInput == true) {
				// 如果选择了相同安装位置或者分开安装
				if ($("input[name='installCase']:checked").val() == 1
						|| $("input[name='installCase']:checked").val() == 0) {
					if ($(object).val() == '罗马杆') {
						$(object).parent().parent().parent().parent().next()
								.show();
					} else {
						toastr.warning("打孔款只能选择罗马杆");
						$(object).parent().parent().parent().parent().next()
								.hide();
						$(object).removeAttr("checked");
					}
				}
			}
		}
		// 如果选择了韩褶或者拉钩款的话
		else if ($("input[name='style']:checked").val() == 3) {
			// 如果选择了相同安装位置或者分开安装
			if ($("input[name='installCase']:checked").val() == 1
					|| $("input[name='installCase']:checked").val() == 0) {
				if ($(object).val() == '罗马杆') {
					$(object).parent().parent().parent().parent().next().show();
				} else {
					$(object).parent().parent().parent().parent().next().hide();
				}
			}
		}
		// 如果选择了帘头款
		else if ($("input[name='style']:checked").val() == 4) {
			// 如果是正在填写布
			if (isCurrentClothSizeInput == true) {
				if ($(object).val() == '罗马杆') {
					toastr.warning("帘头款不能选择罗马杆");
					$(object).removeAttr("checked");
				}
			}
			// 如果是正在填写纱
			if (isCurrentYarnSizeInput == true) {
				if ($(object).val() == '罗马杆') {
					$(object).parent().parent().parent().parent().next().show();
				} else {
					$(object).parent().parent().parent().parent().next().hide();
				}
			}

		}
	}
	$("input[name='pinstallSite']", $(object).closest("form")).removeAttr(
			'checked');
	$("input[name='acc']", $(object).closest("form")).removeAttr('checked');
	$("#selectPanzhuangfangshi", $(object).closest("form")).hide();
	$("input[name='panzhuangfangshi']", $(object).closest("form")).val('');
}
// 更换安装方式
function changePanzhuangfangshi(object) {
	// 如果选择了单层布或单层纱
	if ($("input[name='structure']:checked").val() == 0
			|| $("input[name='structure']:checked").val() == 1) {
		// 如果选择了打孔款
		if ($("input[name='style']:checked").val() == 0) {
			// 如果选择的是窗帘盒安装
			// if ($(object).closest("form").find(
			// "input[name='installSite']:checked").val() == '窗帘盒内安装') {
			// if ($(object).val() == '侧装') {
			// $(object).removeAttr('checked');
			// toastr.error("窗帘盒内安装不能选择侧装");
			// $(object).parent().find('.panzhuangfangshi').val("");
			// } else {
			// $(object).parent().find('.panzhuangfangshi').val("顶装单支架");
			// }
			// }else { // 如果选择的是其他位置
			if ($(object).val() == '侧装') {
				$(object).parent().parent().find('.panzhuangfangshi').val(
						"侧装单支架");
			} else {
				$(object).parent().parent().find('.panzhuangfangshi').val(
						"顶装单支架");
			}
			// }
		}
		// 如果选择了韩褶或者拉钩款的话
		if ($("input[name='style']:checked").val() == 3) {
			// 如果选择了罗马杆
			if ($(object).closest("form").find(
					"input[name='accessoriesType']:checked").val() == '罗马杆') {
				if ($(object).val() == '侧装') {
					$(object).parent().parent().find('.panzhuangfangshi').val(
							"侧装单支架");
				} else {
					$(object).parent().parent().find('.panzhuangfangshi').val(
							"顶装单支架");
				}
			}
			// 如果选择了直轨或者弯轨
			else if ($(object).closest("form").find(
					"input[name='accessoriesType']:checked").val() == '直轨'
					|| $(object).closest("form").find(
							"input[name='accessoriesType']:checked").val() == '弯轨') {
				if ($(object).val() == '侧装') {
					$(object).parent().parent().find('.panzhuangfangshi').val(
							"侧装单安装码");
				} else {
					$(object).parent().parent().find('.panzhuangfangshi').val(
							"顶装单安装码");
				}
			}
		}
		// 如果选择的是帘头款
		if ($("input[name='style']:checked").val() == 4) {
			// 如果选择的是窗帘盒安装
			if ($(object).closest("form").find(
					"input[name='installSite']:checked").val() == '窗帘盒内安装') {
				if ($(object).val() == '侧装') {
					$(object).removeAttr("checked");
					toastr.warning("窗帘盒内安装不能选择侧装");
					$(object).parent().parent().find('.panzhuangfangshi').val(
							"");
				} else {
					$(object).parent().parent().find('.panzhuangfangshi').val(
							"顶装单安装码");
				}
			}
			// 如果是其他位置安装
			else {
				if ($(object).val() == '侧装') {
					$("#selectPanzhuangfangshi", $(object).closest("form"))
							.hide();
					$(object).parent().parent().find('.panzhuangfangshi').val(
							"侧装双联码");
				} else {
					$(object).parent().parent().find('.panzhuangfangshi').val("");
					$("input[name='selectPanzhangpangshi']",
							$(object).closest("form")).removeAttr("checked");
					$("#selectPanzhuangfangshiRadioInput",
							$(object).closest("form")).html("顶装双联码");
					$("#selectPanzhuangfangshiRadio", $(object).closest("form"))
							.val("顶装双联码");
					$("#selectPanzhuangfangshi", $(object).closest("form"))
							.show();
				}
			}
		}
	}

	// 如果是布纱双层
	else {
		// 如果选择了打孔款
		if ($("input[name='style']:checked").val() == 0) {
			// 如果布纱位置相同
			if ($("input[name='installCase']:checked").val() == 1) {
				if ($(object).val() == '侧装') {
					$(object).parent().parent().find('.panzhuangfangshi').val(
							"侧装双支架");
				} else {
					$(object).parent().parent().find('.panzhuangfangshi').val(
							"顶装双支架");
				}
				// 如果选择的是窗帘盒安装
				// if ($(object).closest("form").find(
				// "input[name='installSite']:checked").val() == '窗帘盒内安装') {
				// if ($(object).val() == '侧装') {
				// $(object).removeAttr("checked");
				// toastr.error("窗帘盒内安装不能选择侧装");
				// $(object).parent().find('.panzhuangfangshi').val("");
				// } else {
				// $(object).parent().find('.panzhuangfangshi').val(
				// "顶装双支架");
				// }
				// }
				// // 如果是其他位置安装
				// else {
				//				
				// }
			}
			// 如果选择了布纱分开安装
			else {
				// 如果是正在填写布
				if (isCurrentClothSizeInput == true) {
					if ($(object).val() == '侧装') {
						$(object).parent().parent().find('.panzhuangfangshi')
								.val("侧装单支架");
					} else {
						$(object).parent().parent().find('.panzhuangfangshi')
								.val("顶装单支架");
					}
				}
				// 如果是正在填写纱
				if (isCurrentYarnSizeInput == true) {
					if ($(object).closest("form").find(
							"input[name='accessoriesType']:checked").val() == '罗马杆') {
						if ($(object).val() == '侧装') {
							$(object).parent().parent().find(
									'.panzhuangfangshi').val("侧装单支架");
						} else {
							$(object).parent().parent().find(
									'.panzhuangfangshi').val("顶装单支架");
						}
					} else if ($(object).closest("form").find(
							"input[name='accessoriesType']:checked").val() == '直轨'
							|| $(object).closest("form").find(
									"input[name='accessoriesType']:checked")
									.val() == '弯轨') {
						if ($(object).val() == '侧装') {
							$(object).parent().parent().find(
									'.panzhuangfangshi').val("侧装单安装码");
						} else {
							$(object).parent().parent().find(
									'.panzhuangfangshi').val("顶装单安装码");
						}
					}
				}
			}
		}
		// 如果选择了韩这款或者拉钩款
		else if ($("input[name='style']:checked").val() == 3) {
			// 如果布纱位置相同
			if ($("input[name='installCase']:checked").val() == 1) {
				// if ($(object).closest("form").find(
				// "input[name='installSite']:checked").val() == '窗帘盒内安装') {
				// if ($(object).val() == '侧装') {
				// $(object).removeAttr("checked");
				// toastr.error("窗帘盒内安装不能选择侧装");
				// $(object).parent().find('.panzhuangfangshi').val("");
				// }
				// return;
				// }
				// 如果选择了罗马杆
				if ($(object).closest("form").find(
						"input[name='accessoriesType']:checked").val() == '罗马杆') {
					if ($(object).val() == '侧装') {
						$(object).parent().parent().find('.panzhuangfangshi')
								.val("侧装双支架");
					} else {
						$(object).parent().parent().find('.panzhuangfangshi')
								.val("顶装双支架");
					}
				}
				// 如果是直轨或者弯轨
				else if ($(object).closest("form").find(
						"input[name='accessoriesType']:checked").val() == '直轨'
						|| $(object).closest("form").find(
								"input[name='accessoriesType']:checked").val() == '弯轨') {
					if ($(object).val() == '侧装') {
						$("#selectPanzhuangfangshi", $(object).closest("form"))
								.hide();
						$(object).parent().parent().find('.panzhuangfangshi')
								.val("侧装双联码");
					} else {
						$(object).parent().find('.panzhuangfangshi').val("");
						$("input[name='selectPanzhangpangshi']",
								$(object).closest("form"))
								.removeAttr("checked");
						$("#selectPanzhuangfangshiRadioInput",
								$(object).closest("form")).html("顶装双联码");
						$("#selectPanzhuangfangshiRadio",
								$(object).closest("form")).val("顶装双联码");
						$("#selectPanzhuangfangshi", $(object).closest("form"))
								.show();
					}
				}
			}
			// 如果选择了布纱分开安装
			else {
				// 如果选择了罗马杆
				if ($(object).closest("form").find(
						"input[name='accessoriesType']:checked").val() == '罗马杆') {
					if ($(object).val() == '侧装') {
						$(object).parent().parent().find('.panzhuangfangshi')
								.val("侧装单支架");
					} else {
						$(object).parent().parent().find('.panzhuangfangshi')
								.val("顶装单支架");
					}
				}
				// 如果是直轨
				else if ($(object).closest("form").find(
						"input[name='accessoriesType']:checked").val() == '直轨'
						|| $(object).closest("form").find(
								"input[name='accessoriesType']:checked").val() == '弯轨') {
					if ($(object).val() == '侧装') {
						$(object).parent().parent().find('.panzhuangfangshi')
								.val("侧装单安装码");
					} else {
						$(object).parent().parent().find('.panzhuangfangshi')
								.val("顶装单安装码");
					}
				}
			}
		}

		// 如果选择了帘头款
		else {
			// 如果布纱位置相同
			if ($("input[name='installCase']:checked").val() == 1) {
				// 如果选择的是窗帘盒安装
				// if ($(object).closest("form").find(
				// "input[name='installSite']:checked").val() == '窗帘盒内安装') {
				// if ($(object).val() == '侧装') {
				// $(object).removeAttr("checked");
				// toastr.error("窗帘盒内安装不能选择侧装");
				// $(object).parent().find('.panzhuangfangshi').val("");
				// return;
				// }
				// // 如果是直轨或者弯轨
				// if ($(object).closest("form").find(
				// "input[name='accessoriesType']:checked").val() == '直轨'
				// || $(object).closest("form").find(
				// "input[name='accessoriesType']:checked")
				// .val() == '弯轨') {
				// $(object).parent().find('.panzhuangfangshi').val("");
				// $("input[name='selectPanzhangpangshi']",
				// $(object).closest("form"))
				// .removeAttr("checked");
				// $("#selectPanzhuangfangshiRadioInput",
				// $(object).closest("form")).html("顶装双联码");
				// $("#selectPanzhuangfangshiRadio",
				// $(object).closest("form")).val("顶装双联码");
				// $("#selectPanzhuangfangshi", $(object).closest("form"))
				// .show();
				// }
				// }
				// 如果是其他安装位置
				// else {
				// 如果是直轨或者弯轨
				if ($(object).closest("form").find(
						"input[name='accessoriesType']:checked").val() == '直轨'
						|| $(object).closest("form").find(
								"input[name='accessoriesType']:checked").val() == '弯轨') {
					if ($(object).val() == '侧装') {
						$("#selectPanzhuangfangshi", $(object).closest("form"))
								.hide();
						$(object).parent().parent().find('.panzhuangfangshi')
								.val("侧装三联码");
					} else {
						$(object).parent().parent().find('.panzhuangfangshi')
								.val("");
						$("input[name='selectPanzhangpangshi']",
								$(object).closest("form"))
								.removeAttr("checked");
						$("#selectPanzhuangfangshiRadioInput",
								$(object).closest("form")).text("顶装三联码");
						$("#selectPanzhuangfangshiRadio",
								$(object).closest("form")).val("顶装三联码");
						$("#selectPanzhuangfangshi", $(object).closest("form"))
								.show();

					}
				}
				// }
			}
			// 如果选择了布纱分开安装
			else {
				// 如果是正在填写布
				if (isCurrentClothSizeInput == true) {
					// if ($(object).closest("form").find(
					// "input[name='installSite']:checked").val() == '窗帘盒内安装') {
					// // 如果是直轨或者弯轨
					// if ($(object).closest("form").find(
					// "input[name='accessoriesType']:checked").val() == '直轨'
					// || $(object)
					// .closest("form")
					// .find(
					// "input[name='accessoriesType']:checked")
					// .val() == '弯轨') {
					// if ($(object).val() == '侧装') {
					// toastr.error("窗帘盒内不能选择侧装");
					// $(object).removeAttr('checked');
					// $(object).parent().find('.panzhuangfangshi')
					// .val("");
					// } else {
					// $(object).parent().find('.panzhuangfangshi')
					// .val("顶装单安装码");
					// }
					// }
					// }
					// 如果是其他位置
					// else {
					// 如果是直轨或者弯轨
					if ($(object).closest("form").find(
							"input[name='accessoriesType']:checked").val() == '直轨'
							|| $(object).closest("form").find(
									"input[name='accessoriesType']:checked")
									.val() == '弯轨') {
						if ($(object).val() == '侧装') {
							$(object).parent().parent().find(
									'.panzhuangfangshi').val("侧装双联码");
							$("#selectPanzhuangfangshi",
									$(object).closest("form")).hide();
						} else {
							$(object).parent().parent().find(
									'.panzhuangfangshi').val("");
							$("input[name='selectPanzhangpangshi']",
									$(object).closest("form")).removeAttr(
									"checked");
							$("#selectPanzhuangfangshiRadioInput",
									$(object).closest("form")).text("顶装双联码");
							$("#selectPanzhuangfangshiRadio",
									$(object).closest("form")).val("顶装双联码");
							$("#selectPanzhuangfangshi",
									$(object).closest("form")).show();
						}
					}
					// }
				}
				// 如果是正在填写纱
				if (isCurrentYarnSizeInput == true) {
					// if ($(object).closest("form").find(
					// "input[name='installSite']:checked").val() == '窗帘盒内安装') {
					// // 如果是罗马杆
					// if ($(object).closest("form").find(
					// "input[name='accessoriesType']:checked").val() == '罗马杆')
					// {
					// if ($(object).val() == '侧装') {
					// toastr.error("窗帘盒内不能选择侧装");
					// $(object).removeAttr('checked');
					// $(object).parent().find('.panzhuangfangshi')
					// .val("");
					// } else {
					// $(object).parent().find('.panzhuangfangshi')
					// .val("顶装单支架");
					// }
					// }
					// // 如果是直轨或者弯轨
					// if ($(object).closest("form").find(
					// "input[name='accessoriesType']:checked").val() == '直轨'
					// || $(object)
					// .closest("form")
					// .find(
					// "input[name='accessoriesType']:checked")
					// .val() == '弯轨') {
					// if ($(object).val() == '侧装') {
					// toastr.error("窗帘盒内不能选择侧装");
					// $(object).removeAttr('checked');
					// $(object).parent().find('.panzhuangfangshi')
					// .val("");
					// } else {
					// $(object).parent().find('.panzhuangfangshi')
					// .val("顶装单安装码");
					// }
					// }
					// }// 如果是其他位置安装
					// else {
					// 如果选择了罗马杆
					if ($(object).closest("form").find(
							"input[name='accessoriesType']:checked").val() == '罗马杆') {
						if ($(object).val() == '侧装') {
							$(object).parent().parent().find(
									'.panzhuangfangshi').val("侧装单支架");
						} else {
							$(object).parent().parent().find(
									'.panzhuangfangshi').val("顶装单支架");
						}
					}
					// 如果选择了直轨或者弯轨
					else if ($(object).closest("form").find(
							"input[name='accessoriesType']:checked").val() == '直轨'
							|| $(object).closest("form").find(
									"input[name='accessoriesType']:checked")
									.val() == '弯轨') {
						if ($(object).val() == '侧装') {
							$(object).parent().parent().find(
									'.panzhuangfangshi').val("侧装单安装码");
						} else {
							$(object).parent().parent().find(
									'.panzhuangfangshi').val("顶装单安装码");
						}
					}
					// }
				}
			}
		}
	}
	// 移除 移除 移除
	$("input[name='panzhuangfangshi']", $(object).closest("form")).removeAttr(
			"checked");
}

// 添加配件
function changeSelectPanzhuangfangshi(object) {
	$("input[class='panzhuangfangshi']", $(object).closest("form")).val(
			$(object).val());
}
function makeInput(labContent, placeholder, name) {
	var div = $('<div class="form-group"></div>');
	var label = $('<label class="col-md-3 col-sm-3 control-label">'
			+ labContent + '：</label>');
	var input = ('<div class="col-md-6"><input type="text" placeholder="'
			+ placeholder + '" class="form-control" name="' + name + '"/></div>');
	div.append(label);
	div.append(input);
	return div;
}

// 做radio
function makeRadio(name, value, change, content) {
	var lableInput = '<input type="radio" class="toggle" name="' + name
			+ '"  value="' + value + '" onchange="' + change + '"/>' + content
			+ '您好我是单层布&nbsp;&nbsp;';
	return lableInput;
}

// 做radio父div
function makeRadioFather(name, id) { // left:315
	return '<div class="form-group"><label class="col-md-2 col-sm-2 control-label">'
			+ name
			+ '：</label><div class="clearfix"><div id="'
			+ id
			+ '"  class="btn-group"  style="margin-top: 6px"></div></div></div>';
}
// 更改帘的类型 主要是成品帘和布艺帘
function changeCurtainType(object) {
	// if (typeof $("input[name='locationId']:checked").val() == 'string'
	// || typeof $("input[name='locationId']:checked").val() == 'number') {
	$(object, $("#goodDetailForm")).parent().parent().parent().nextAll().find(
			"input[type=radio]").removeAttr("checked");

	$("#button_addSizeDIV").find(".button-size-custom").hide();

	// 如果是布艺窗帘
	if ($(object).val() == 0) {
		// alert("布艺窗帘==="+$(object).val());
		$('#basicClothCurtainOptionDIV').show();
	} else if ($(object).val() == 1) {
		// alert("成品窗帘==="+$(object).val()+"********"+"选择成品窗帘尺寸---"+isProductSizeInput);
		$("#button_addSizeDIV #button_addSize_1").show();
		uploadGoodTypeStatus = 1;
		$('#basicClothCurtainOptionDIV').hide();
	}
	// } else {
	// $(object).removeAttr("checked");
	// toastr.error("请先选择或填写房间");
	// }
	initialAllAddCurtainSizeModal();
}
function changeClothCurtainStructure(object) {
	$(object, $("#goodDetailForm")).parent().parent().parent().nextAll().find(
			"input[type=radio]").removeAttr("checked");
	// 如果是布纱双层的话就显示安装情况 主要就是布纱位置一致不一致
	if ($(object).val() == 2) {
		$("#button_addSizeDIV").find(".button-size-custom").hide();
		$('#intallClothCurtainSituatonDIV').show();
	} else if ($(object).val() == 1) {
		$("#button_addSizeDIV").find(".button-size-custom").hide();
		$('#intallClothCurtainSituatonDIV').hide();
	} else {
		$("#button_addSizeDIV").find(".button-size-custom").hide();
		$('#intallClothCurtainSituatonDIV').hide();
	}
	initialAllAddCurtainSizeModal();
}
// 更改布艺帘Style 目前只有三种 0 3 4
function changeClothCurtainStyle(object) {
	$(object, $("#goodDetailForm")).parent().parent().parent().nextAll().find(
			"input[type=radio]").removeAttr("checked");
	if ($("#intallClothCurtainSituatonDIV").is(':visible')) {
		$("#button_addSizeDIV").find(".button-size-custom").hide();
		return;
	}
	$("#button_addSizeDIV").find(".button-size-custom").hide();
	// 如果选中了单层布
	if ($("input[name='structure']:checked").val() == 0) {
		// 如果没有选中帘头款
		if ($(object).val() == 0 || $(object).val() == 3) {
			$("#button_addSizeDIV #button_addSize_3").show();
			uploadGoodTypeStatus = 3;
			$('#intallClothCurtainSituatonDIV').hide();
		} else {
			uploadGoodTypeStatus = 5;
			$("#button_addSizeDIV #button_addSize_5").show();
		}
	}// 如果选中了单层纱
	else if ($("input[name='structure']:checked").val() == 1) {
		// 如果没有选中帘头款
		if ($(object).val() == 0 || $(object).val() == 3) {
			uploadGoodTypeStatus = 2;
			$("#button_addSizeDIV #button_addSize_2").show();
			$('#intallClothCurtainSituatonDIV').hide();
		} else {
			uploadGoodTypeStatus = 4;
			$("#button_addSizeDIV #button_addSize_4").show();
		}
	}
	// 如果选中了布纱双层
	else {

		// $("#button_addSizeDIV").find(".button-size-custom").hide();
	}
	initialAllAddCurtainSizeModal();
}
// 选择安装情况是否一致的处理
function changeClothCurtainInstallSituation(object) {
	$("#button_addSizeDIV").find(".button-size-custom").hide();
	// 如果不是帘头款
	if ($("input[name='style']:checked").val() == 0
			|| $("input[name='style']:checked").val() == 3) {
		if ($(object).val() == 1) {
			uploadGoodTypeStatus = 7;
			$("#button_addSizeDIV #button_addSize_7").show();
		} else {
			uploadGoodTypeStatus = 9;
			$("#button_addSizeDIV #button_addSize_9").show();
		}
	} else if ($("input[name='style']:checked").val() == 4) {
		if ($(object).val() == 1) {
			uploadGoodTypeStatus = 6;
			$("#button_addSizeDIV #button_addSize_6").show();
		} else {
			uploadGoodTypeStatus = 8;
			$("#button_addSizeDIV #button_addSize_8").show();
		}
	}
	initialAllAddCurtainSizeModal();
}
// 选择其他房间的处理
function changeInstallRoom(object) {
	// 点击其他房间radio后 会可输入其他房间的input text
	if ($(object).val() == -1) {
		$('#otherRoom_input').val('');
		$('#otherRoom_input').removeAttr("disabled");
	} else {
		$('#otherRoom_input').val('');
		$('#otherRoom_input').attr("disabled", "disabled");
	}
}
// 添加成品帘尺寸modal开启
function click_addProductCurtainSize() {
	// 设置输入框
	$(".custom-input-curtainSizeMeter", $('#addProductCurtainForm-0'))
			.TouchSpin({
				min : 0,
				max : 20,
				step : 0.01,
				decimals : 2,
				boostat : 5,
				maxboostedstep : 10,
				postfix : '米'
			});
	isCurrentProductSizeInput = false;
	$('#addProductCurtainSizeModal').modal('show');
}
// 添加布艺帘布尺寸modal开启
function click_addClothCurtainClothSize() {
	closeAddHeadSizeForm();
	// 如果选择了帘头款的布艺帘按钮 则每个尺寸都只能添加一个 因此隐藏删除和添加尺寸按钮
	if ($("#basicClothCurtainOptionDIV input[name='style']:checked").val() == 4) {
		$(".custom-deleteAddCurtainForm").hide();
		$(".custom-newAddCurtainForm").hide();
	}
	$(".custom-input-curtainSizeMeter", $('#addClothCurtainClothSizeForm-0'))
			.TouchSpin({
				min : 0,
				max : 20,
				step : 0.01,
				decimals : 2,
				boostat : 5,
				maxboostedstep : 10,
				postfix : '米'
			});
	isCurrentClothSizeInput = true;
	$('#addClothCurtainClothSizeModal').modal('show');
}
// 添加布艺帘啥尺寸modal开启
function click_addClothCurtainYarnSize() {
	closeAddHeadSizeForm();
	// 如果选择了帘头款的布艺帘按钮 则每个尺寸都只能添加一个 因此隐藏删除和添加尺寸按钮
	if ($("#basicClothCurtainOptionDIV input[name='style']:checked").val() == 4) {
		$(".custom-deleteAddCurtainForm").hide();
		$(".custom-newAddCurtainForm").hide();
	}
	$(".custom-input-curtainSizeMeter", $('#addClothCurtainYarnSizeForm-0'))
			.TouchSpin({
				min : 0,
				max : 20,
				step : 0.01,
				decimals : 2,
				boostat : 5,
				maxboostedstep : 10,
				postfix : '米'
			});
	isCurrentYarnSizeInput = true;
	$('#addClothCurtainYarnSizeModal').modal('show');

}
// 添加帘头尺寸modal开启
function click_addClothCurtainHeadShadeSize() {
	// 如果是单层布的结构的话
	if ($("input[name='structure']:checked").val() == 0) {
		if (isClothSizeInput == false) {
			toastr.warning("请先填写布尺寸！");
		} else {
			initialInputMeterTouchSpinForm($('#addClothCurtainHeadShadeSizeForm-0'));
			// 打开modal之前需要判断帘头轨的配件
			if ($("input[name='installSite']:checked",
					$("#addClothCurtainClothSizeDIV")).val() != "窗帘盒内安装") {
				if ($("input[name='accessoriesType']:checked",
						$("#addClothCurtainClothSizeDIV")).val() == '直轨'
						|| $("input[name='accessoriesType']:checked",
								$("#addClothCurtainClothSizeDIV")).val() == '弯轨') {
					if ($("input[name='panzhuangfangshi']",
							$("#addClothCurtainClothSizeDIV")).val() == '顶装单安装码') {
						$("input[name='parsOfPars']",
								$("#addClothCurtainHeadShadeSizeDIV")).val(
								'顶装单安装码');
					}
				}
			} else {
				$("input[name='parsOfPars']",
						$("#addClothCurtainHeadShadeSizeDIV")).val('无');
			}
			var _headLen = $("input[name='saleNumber']",
					$("#addClothCurtainClothSizeDIV")).val();
			$("input[name='saleNumber']", $("#addClothCurtainHeadShadeSizeDIV"))
					.val(_headLen);
			$("input[name='wide']", $("#addClothCurtainHeadShadeSizeDIV")).val(
					_headLen);
			$('#addClothCurtainHeadShadeSizeModal').modal('show');
		}
	}
	// 如果是单层纱的结构的话
	else if ($("input[name='structure']:checked").val() == 1) {
		if (isYarnSizeInput == false) {
			toastr.warning("请先填写纱尺寸！");
		} else {
			initialInputMeterTouchSpinForm($('#addClothCurtainHeadShadeSizeForm-0'));
			// 打开modal之前需要判断帘头轨的配件
			if ($("input[name='installSite']:checked",
					$("#addClothCurtainYarnSizeDIV")).val() != "窗帘盒内安装") {
				if ($("input[name='accessoriesType']:checked",
						$("#addClothCurtainYarnSizeDIV")).val() == '直轨'
						|| $("input[name='accessoriesType']:checked",
								$("#addClothCurtainYarnSizeDIV")).val() == '弯轨') {
					if ($("input[name='panzhuangfangshi']",
							$("#addClothCurtainYarnSizeDIV")).val() == '顶装单安装码') {
						$("input[name='parsOfPars']",
								$("#addClothCurtainHeadShadeSizeDIV")).val(
								'顶装单安装码');
					}
				}
			} else {
				$("input[name='parsOfPars']",
						$("#addClothCurtainHeadShadeSizeDIV")).val('无');
			}
			var _headLen = $("input[name='saleNumber']",
					$("#addClothCurtainYarnSizeDIV")).val();
			$("input[name='saleNumber']", $("#addClothCurtainHeadShadeSizeDIV"))
					.val(_headLen);
			$("input[name='wide']", $("#addClothCurtainHeadShadeSizeDIV")).val(
					_headLen);
			$('#addClothCurtainHeadShadeSizeModal').modal('show');
		}
	} else {
		if (isClothSizeInput == false) {
			toastr.warning("布和纱尺寸没有填写完整！");
		} else {
			initialInputMeterTouchSpinForm($('#addClothCurtainHeadShadeSizeForm-0'));
			// 打开modal之前需要判断帘头轨的配件
			if ($("input[name='installSite']:checked",
					$("#addClothCurtainClothSizeDIV")).val() != "窗帘盒内安装") {
				if ($("input[name='accessoriesType']:checked",
						$("#addClothCurtainClothSizeDIV")).val() == '直轨'
						|| $("input[name='accessoriesType']:checked",
								$("#addClothCurtainClothSizeDIV")).val() == '弯轨') {
					if ($("input[name='panzhuangfangshi']",
							$("#addClothCurtainClothSizeDIV")).val() == '顶装单安装码') {
						$("input[name='parsOfPars']",
								$("#addClothCurtainHeadShadeSizeDIV")).val(
								'顶装单安装码');
					}
				}
			} else {
				$("input[name='parsOfPars']",
						$("#addClothCurtainHeadShadeSizeDIV")).val('无');
			}
			var _headLen = $("input[name='saleNumber']",
					$("#addClothCurtainClothSizeDIV")).val();
			$("input[name='saleNumber']", $("#addClothCurtainHeadShadeSizeDIV"))
					.val(_headLen);
			$("input[name='wide']", $("#addClothCurtainHeadShadeSizeDIV")).val(
					_headLen);
			$('#addClothCurtainHeadShadeSizeModal').modal('show');
		}
	}
}

// 删除一个添加成品帘尺寸的form
function deleteAddProductCurtainOption(object) {
	if ($("#addProductCurtainSizeDIV").find('form').size() != 1) {
		$(object).closest("form").remove();
	}
}
// 删除一个添加布艺帘布尺寸的form
function deleteAddClothCurtainClothSizeOption(object) {
	if ($("#addClothCurtainClothSizeDIV").find('form').size() != 1) {
		$(object).closest("form").remove();
	}
}
// 删除一个布艺帘纱帘尺寸的form
function deleteAddClothCurtainYarnSizeOption(object) {
	if ($("#addClothCurtainYarnSizeDIV").find('form').size() != 1) {
		$(object).closest("form").remove();
	}
}
// 添加一个成品帘尺寸的form
function addProductCurtainSize_click() {
	if (validateAddProductSizeForms() == true) {
		var newAddProductCurtainForm = initialAddProductCurtainForm
				.cloneNode(true)
		newAddProductCurtainForm.reset()
		$("#addProductCurtainSizeDIV").append(newAddProductCurtainForm);
		initialInputMeterTouchSpinForm(newAddProductCurtainForm);
	} else {
		toastr.warning("信息填写完整后再添加尺寸");
	}
}

// 添加一个布艺帘布尺寸的form
function addClothCurtainClothSize_click() {
	if (validateAddClothSizeForms() == true) {
		var newAddClothCurtainClothSizeForm = initialAddClothCurtainClothSizeForm
				.cloneNode(true)
		newAddClothCurtainClothSizeForm.reset()
		$("#addClothCurtainClothSizeDIV").append(
				newAddClothCurtainClothSizeForm);
		initialInputMeterTouchSpinForm(newAddClothCurtainClothSizeForm);
	} else {
		toastr.warning("信息填写完整后再添加尺寸");
	}
}
// 添加一个布艺帘纱尺寸的form
function addClothCurtainYarnSize_click() {
	if (validateAddYarnSizeForms() == true) {
		var newAddClothCurtainYarnSizeForm = initialAddClothCurtainYarnSizeForm
				.cloneNode(true)
		newAddClothCurtainYarnSizeForm.reset()
		$("#addClothCurtainYarnSizeDIV").append(newAddClothCurtainYarnSizeForm);
		initialInputMeterTouchSpinForm(newAddClothCurtainYarnSizeForm);
	} else {
		toastr.warning("信息填写完整后再添加尺寸");
	}
}
// 订单添加商品
function addGoodForIndent_click(btn) {
	/*
	 * var filesCount = $('#avatar-1').fileinput('getFilesCount'); if
	 * (filesCount != 0) { $("#avatar-1").fileinput("upload"); } else {
	 */
	submitInstallIndentGood(btn);
	/* } */
}
// 字符串工具类
function updateString(data) {
	data = data.replace(/&/g, "\",\"");
	data = data.replace(/=/g, "\":\"");
	data = "{\"" + data + "\"}";
	return data;
}
// 删除商品
function deleteFakeGood(goodID) {
	var fakeGoodID = "" + goodID;
	Ewin.confirm({
		message : "是否确定删除该商品？"
	}).on(function(e) {
		if (!e) {
			return;
		}
		$.post("../indent/deleteFakeGood", {
			goodID : fakeGoodID,
			indentID : fakeIndentID
		}, function(data) {
			refreshIndentGoodTable();
		});
	})
}
var fakeGoodsList = new Array;
// 加载订单商品表格
function loadIndentGoodTable() {
	$('#indentGoods_Table')
			.bootstrapTable(
					{
						toolbar : '#toolbar', // 工具按钮用哪个容器
						height : 500,
						columns : [
								{
									field : 'type_script', //
									title : '安装基本信息',
									align : "center",
									width : "15%",
									formatter : function(value, row, index) {
										var curtainTypeStr = !row.good.curtainTypeStr ? "无"
												: row.good.curtainTypeStr;
										var installPrice = !row.good.installPrice ? "无"
												: row.good.installPrice;
										var basic = "品种  :"
												+ curtainTypeStr
												+ "<br/>"
												+ "安装费用  :"
												+ installPrice
												+ "元"
												+ "<br/>"
												+ "<a href='javascript:deleteFakeGood("
												+ row.good.goodsId
												+ ")'>删除商品</a>";
										return basic;
									}
								},
								{
									field : 'good',
									title : '安装信息',
									align : "center",
									width : "15%",
									formatter : function(value, row, index) {
										/*
										 * var installCase = value.installCase ==
										 * 1? "<br/>布纱安装位置：相同" : ""; var
										 * structureStr=! value.structureStr ?
										 * "无": value.structureStr ; var
										 * styleStr=! value.styleStr ? "无":
										 * value.styleStr ; var
										 * goodSpecialTypeStr=!
										 * row.goodSpecialTypeStrt ? "无":
										 * row.goodSpecialTypeStrt ; if
										 * (value.type == 0) { return "结构：" +
										 * structureStr + "<br/>款式：" + styleStr + "<br/>类型：" +
										 * goodSpecialTypeStr + installCase; }
										 * else { return
										 * "类型："+goodSpecialTypeStr; }
										 */
										var info;
										var installCase = value.installCase == 1 ? "<br/>布纱安装位置：相同"
												: "";
										var structureStr = !value.structureStr ? "无"
												: value.structureStr;
										var styleStr = !value.styleStr ? "无"
												: value.styleStr;
										var goodSpecialTypeStr = !value.goodSpecialTypeStr ? "无"
												: value.goodSpecialTypeStr;
										if (value.type == 0) {

											info = "结构：" + structureStr
													+ "<br/>款式：" + styleStr
													+ "<br/>类型："
													+ goodSpecialTypeStr
													+ installCase;
										} else {
											info = "类型：" + goodSpecialTypeStr;

										}
										return info;
									}
								},
								{
									field : 'type',
									title : '款式信息',
									align : "left",
									width : "20%",
									formatter : function(value, row, index) {
										/*
										 * var accessoriesType=!
										 * row.accessoriesType ? "无" :
										 * row.accessoriesType; var
										 * pinstallSite=! row.pinstallSite ? "无" :
										 * row.pinstallSite; var accStr=!
										 * row.acc ? "无装饰头" : row.acc; var
										 * panzhuangfangshi=!
										 * row.panzhuangfangshi ? "无" :
										 * row.panzhuangfangshi; var
										 * installSite=! row.installSite ? "无" :
										 * row.installSite; // 如果是布尺寸或者纱尺寸 if
										 * (value == 0 || value == 1) { return
										 * "布帘安装位置：" + installSite + "<br/>布帘配件：" +
										 * accessoriesType + "，" + accStr + "<br/>安装方式：" +
										 * pinstallSite + "<br/>安装配件：" +
										 * panzhuangfangshi; }else if (value ==
										 * 2) {// 如果是帘头 return "帘头安装情况："
										 * +installSite + "<br/>帘头配件：" +
										 * accessoriesType; }else {// 如果是成品帘
										 * return "无"; }
										 */
										var kuashi = "";
										var accessoriesType = !row.accessoriesType ? "无"
												: row.accessoriesType;
										var pinstallSite = !row.pinstallSite ? "无"
												: row.pinstallSite;
										var accStr = !row.acc ? "无装饰头"
												: row.acc;
										var panzhuangfangshi = !row.panzhuangfangshi ? "无"
												: row.panzhuangfangshi;
										// 如果是布尺寸或者纱尺寸
										if (value == 0 || value == 1) {
											kuashi = "布帘配件：" + accessoriesType
													+ "，" + accStr
													+ "<br/>安装方式："
													+ pinstallSite
													+ "<br/>安装配件："
													+ panzhuangfangshi;
										}
										// 如果是帘头
										else if (value == 2) {
											kuashi = "帘头安装情况：" + pinstallSite

											+ "<br/>帘头配件：" + accessoriesType;
										}
										// 如果是成品帘
										else {
											kuashi = "无";
										}
										return kuashi;
									}
								},
								{
									field : 'type',
									title : '尺寸信息',
									align : "center",
									width : "200px",
									formatter : function(value, row, index) {
										/*
										 * // 如果是布尺寸或者纱尺寸 var width=! row.wide ?
										 * "0.0" : row.wide; var high=! row.high ?
										 * "0.0" : row.high; var saleNumber=!
										 * row.saleNumber ? "0.0" :
										 * row.saleNumber; if (value == 0 ||
										 * value == 1) { return "宽：" +width +
										 * "（米），高：" + high + "（米）" + "<br/>杆长：" +
										 * width + "（米）"; }else if (value == 2)
										 * {// 如果是帘头 return "宽：" + width +
										 * "（米），配件长度：" + saleNumber; }else {//
										 * 如果是成品帘 return "宽：" + width + "（米），高：" +
										 * high + "（米）"; }
										 */
										// 如果是布尺寸或者纱尺寸
										var size;
										var width = !row.wide ? "0" : row.wide;
										var high = !row.high ? "0" : row.high;
										var saleNumber = !row.saleNumber ? "0"
												: row.saleNumber;
										if (value == 0 || value == 1) {

											size = "宽：" + width + "（米），高："
													+ high

													+ "（米）" + "<br/>杆长："
													+ saleNumber + "（米）";
										}
										// 如果是帘头
										else if (value == 2) {

											size = "宽：" + width

											+ "（米），配件长度：" + saleNumber;
										}
										// 如果是成品帘
										else {

											size = "宽：" + width + "（米），高："
													+ high

													+ "（米）";
										}
										return size;
									}
								}, {
									field : 'remark',
									title : '备注',
									width : "15%",
									align : "center"
								} ]
					});
}

// 刷新表格信息
function refreshIndentGoodTable() {
	var cityCodeStr = $("#stepy_form").find("select[name='province']").val()
			+ "/" + $("#stepy_form").find("select[name='city']").val();

	$.post("../good/refreshInstallIndentGoods", {
		fakeIndentID : fakeIndentID,
		cityCodeStr : cityCodeStr
	}, function(data) {
		initialAddProductCurtainSizeForm();
		initialClothCurtainClothSizeForm();
		initialClothCurtainYarnSizeForm();

		$('#indentGoods_Table').bootstrapTable('load', data.goodPart);
		var beginNum = 0;
		$.each(data.collapseNumbers, function(index, valueChild) {
			$('#indentGoods_Table').bootstrapTable('mergeCells', {
				index : beginNum,
				field : 'type_script',
				rowspan : valueChild,
			});
			$('#indentGoods_Table').bootstrapTable('mergeCells', {
				index : beginNum,
				field : 'good_script',
				rowspan : valueChild,
			});
			beginNum = beginNum + valueChild;
		})
	});
}
// 0未保存成品帘尺寸 1为保存布艺帘布尺寸 2为保存布艺帘纱尺寸 3为保存帘头尺寸
function keepCurtainSize_click(type) {
	if (type == 0) {
		// alert(0);
		if (validateAddProductSizeForms() == true) {
			$('#addProductCurtainSizeModal').modal('hide');
			isProductSizeInput = true;
		} else {
			toastr.warning("请信息填写完整后再保存尺寸");
		}
	}
	if (type == 1) {
		// alert(1);
		if (validateAddClothSizeForms() == true) {
			$("#addClothCurtainClothSizeModal").modal('hide');
			isClothSizeInput = true;
			isCurrentClothSizeInput = false;
		} else {
			toastr.warning("请信息填写完整后再保存尺寸");
		}
	}
	if (type == 2) {
		// alert(2);
		if (validateAddYarnSizeForms() == true) {
			$("#addClothCurtainYarnSizeModal").modal('hide');
			isYarnSizeInput = true;
			isCurrentYarnSizeInput = false;
		} else {
			toastr.warning("请信息填写完整后再保存尺寸");
		}
	}
	if (type == 3) {
		// alert(3);
		if (validateAddHeadSizeForms() == true) {
			$("#addClothCurtainHeadShadeSizeModal").modal('hide');
			isCurrentHeadSizeInput = false;
			isHeadSizeInput = true;
		} else {
			toastr.warning("请信息填写完整后再保存尺寸");
		}
	}
	changeInputSizeStatusText();
}

// 初始化三个添加标签modal 并且关闭按钮
function initialAllAddCurtainSizeModal() {
	initialAddProductCurtainSizeForm();
	initialClothCurtainClothSizeForm();
	initialClothCurtainYarnSizeForm();
	closeAddHeadSizeForm();
}

// 初始化添加成品尺寸
function initialAddProductCurtainSizeForm() {
	$("#addProductCurtainSizeDIV").find('form').remove();
	var newAddProductCurtainForm = initialAddProductCurtainForm.cloneNode(true)
	newAddProductCurtainForm.reset();
	$("#addProductCurtainSizeDIV").append(newAddProductCurtainForm);
	isProductSizeInput = false;
	changeInputSizeStatusText();
}
// 初始化添加布艺帘布尺寸
function initialClothCurtainClothSizeForm() {
	$("#addClothCurtainClothSizeDIV").find('form').remove();
	var newAddClothCurtainClothSizeForm = initialAddClothCurtainClothSizeForm
			.cloneNode(true)
	newAddClothCurtainClothSizeForm.reset()
	$("#addClothCurtainClothSizeDIV").append(newAddClothCurtainClothSizeForm);
	isClothSizeInput = false;
	isCurrentClothSizeInput = false;
	changeInputSizeStatusText();
}
// 初始化添加布艺帘纱尺寸
function initialClothCurtainYarnSizeForm() {
	$("#addClothCurtainYarnSizeDIV").find('form').remove();
	var newAddClothCurtainYarnSizeForm = initialAddClothCurtainYarnSizeForm
			.cloneNode(true)
	newAddClothCurtainYarnSizeForm.reset();
	$("#addClothCurtainYarnSizeDIV").append(newAddClothCurtainYarnSizeForm);
	isYarnSizeInput = false;
	isCurrentYarnSizeInput = false;
	changeInputSizeStatusText();
}
// 关闭帘头尺寸信息
function closeAddHeadSizeForm() {
	$('#addClothCurtainHeadShadeSizeForm-0')[0].reset();
	isHeadSizeInput = false;
	isCurrentHeadSizeInput = false;
	$("#headSizeInstallSiteSituation").hide();
	changeInputSizeStatusText();
}
function changeInputSizeStatusText() {
	if (isProductSizeInput == false) {
		$(".custom-addProductSize-button").removeClass('btn-success');
		$(".custom-addProductSize-button").addClass('btn-danger');
		$(".custom-addProductSize-button").text('添加成品帘尺寸[未填]');
	} else {
		$(".custom-addProductSize-button").removeClass('btn-danger');
		$(".custom-addProductSize-button").addClass('btn-success');
		$(".custom-addProductSize-button").text('添加成品帘尺寸[已填]');
	}
	if (isClothSizeInput == false) {
		$(".custom-addClothSize-button").removeClass('btn-success');
		$(".custom-addClothSize-button").addClass('btn-danger');
		$(".custom-addClothSize-button").text('添加布帘尺寸[未填]');
	} else {
		$(".custom-addClothSize-button").removeClass('btn-danger');
		$(".custom-addClothSize-button").addClass('btn-success');
		$(".custom-addClothSize-button").text('添加布帘尺寸[已填]');
	}
	if (isYarnSizeInput == false) {
		$(".custom-addYarnSize-button").removeClass('btn-success');
		$(".custom-addYarnSize-button").addClass('btn-danger');
		$(".custom-addYarnSize-button").text('添加纱帘尺寸[未填]');
	} else {
		$(".custom-addYarnSize-button").removeClass('btn-danger');
		$(".custom-addYarnSize-button").addClass('btn-success');
		$(".custom-addYarnSize-button").text('添加纱帘尺寸[已填]');
	}
	if (isHeadSizeInput == false) {
		$(".custom-addHeadSize-button").removeClass('btn-success');
		$(".custom-addHeadSize-button").addClass('btn-danger');
		$(".custom-addHeadSize-button").text('添加帘头尺寸[未填]');
	} else {
		$(".custom-addHeadSize-button").removeClass('btn-danger');
		$(".custom-addHeadSize-button").addClass('btn-success');
		$(".custom-addHeadSize-button").text('添加帘头尺寸[已填]');
	}
}
// -------------------添加基本信息添加基本信息添加基本信息添加基本信息
function loadAccessoryInputTouchSpin(cityCode) {
	if (cityCode.indexOf("999999") > 0 || cityCode.indexOf("999999") == 0) {
		$("#input_needPickupPrice").val("");
	} else {
		$.post("../cityCostRule/queryCostRuleByCityCode", {
			cityCode : cityCode
		}, function(data) {
			costRules = data;
			$("#input_needPickupPrice").val(data.takeGoodsPrice + "元");
		});
	}
}
// 添加安装订单
function makeInstallIndent(object) {
	$("#stepy_form input[name='fakeIndentID']").val(fakeIndentID);
	$(object).removeClass('btn-info');
	$(object).addClass('btn-warning');
	$(object).html("生成中...");
	$(object).attr('disabled', 'disabled');
	$
			.post(
					"../indent/makeInstallIndent",
					$("#stepy_form").serialize(),
					function(data) {
						if (data.status == 0) {
							$("input[name='indentID']").val(data.data.indentID);
							indentPrice = data.data.price;
							realIndentPrice = data.data.merchantsRealPrice;
							$(object).removeClass('btn-warning');
							$(object).addClass('btn-info');
							$(object).html("生成订单");
							countIndentPrice(realIndentPrice);
							$(object).removeAttr('disabled');
							$("#stepy_form")[0].reset();
							$("#City>option:nth-child(1)").attr("selected",
									"selected"); // 给县默认赋值为第一个；
							$("#countrySelect>option:nth-child(1)").attr(
									"selected", "selected"); // 给县默认赋值为第一个；
							$("#txt_crampetPrice").html(
									"壁钩安装费" + costRules.crampetPrice + "元/对");
							$("#txt_fourClawPrice").html(
									"四抓钩安装费" + costRules.fourClawPrice + "元/套");
							$("#txt_motorPrice").html(
									"电机安装费" + costRules.motorPrice + "元/台");
							$("#payIndentModal").modal('show');
						}
					});
}
// 更改是否需要取货信息
function changeNeedPickUpForIndent(radio) {
	if (radio.value == 0) {
		$("#pickupDetailDIV").hide();
	} else {
		$("#pickupDetailDIV").show();
	}
}
// 更改安装位置
function changeInstallSite(object) {
	$("input[name='pinstallSite']", $(object).closest("form")).removeAttr(
			'checked');
	$("input[name='acc']", $(object).closest("form")).removeAttr('checked');
	$("#selectPanzhuangfangshi", $(object).closest("form")).hide();
	$("input[name='panzhuangfangshi']", $(object).closest("form")).val('');
	$("input[name='panzhuangfangshi']", $(object).closest("form")).removeAttr(
			"checked");
}
// 关闭选择商品基本信息的modal初始化
function closeGoodDetailChooseForm() {
	$('#basicClothCurtainOptionDIV').hide();
	$("#button_addSizeDIV").find(".button-size-custom").hide();
	/* $("#goodDetailForm input[name='goodImage']").val(""); */
	/* $('#avatar-1').fileinput('reset').fileinput('enable'); */
	$("input[type='radio']", $('#goodDetailForm')).removeAttr('checked');
}
// 获取一个假的订单号
function randomChar(l) {
	var x = "0123456789qwertyuioplkjhgfdsazxcvbnm";
	var tmp = "";
	var timestamp = new Date().getTime();
	for (var i = 0; i < l; i++) {
		tmp += x.charAt(Math.ceil(Math.random() * 100000000) % x.length);
	}
	return timestamp + tmp;
}
// 初始化当前form的touchspin
function initialInputMeterTouchSpinForm(currentForm) {
	$(".custom-input-curtainSizeMeter", $(currentForm)).TouchSpin({
		min : 0,
		max : 20,
		step : 0.01,
		decimals : 2,
		boostat : 5,
		maxboostedstep : 10,
		postfix : '米'
	});
}
// 加载初始化
function initialCurrentPage() {
	// 手机号码验证
	jQuery.validator
			.addMethod(
					"isMobile",
					function(value, element) {
						var length = value.length;
						var mobile = /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/;
						var re = /^0\d{2,3}-?\d{7,8}$/;
						return this.optional(element)
								|| (length == 11 && mobile.test(value))
								|| re.test(value);
					}, "请正确填写您的电话号码");
	loadIndentGoodTable();
	$("#button_addSizeDIV").find(".button-size-custom").hide();
	var btnCust = '<button type="button" class="btn btn-default" title="Add picture tags" '
			+ 'onclick="alert(\'Call your custom code here.\')">'
			+ '<i class="glyphicon glyphicon-tag"></i>' + '</button>';
	/*
	 * $("#avatar-1") .fileinput( { language : 'zh', // 设置语言 uploadUrl :
	 * "/lukebang/picture/getImageB64", // 上传的地址 allowedFileExtensions : [
	 * 'jpg', 'png', 'gif' ],// 接收的文件后缀 overwriteInitial : true, maxFileSize :
	 * 1500, showClose : false, showCaption : false, showUpload : false,
	 * showUpload : false, showRemove : false, // showPreview : false,
	 * showUploadedThumbs : false, showCancel : false, browseLabel : '',
	 * removeLabel : '', maxFileCount : 1, // 表示允许同时上传的最大文件个数 enctype :
	 * 'multipart/form-data', validateInitialCount : true, elErrorContainer :
	 * '#kv-avatar-errors-1', msgErrorClass : 'alert alert-block alert-danger',
	 * defaultPreviewContent : '<img src="../static/images/login-logo3.jpg"
	 * alt="Your Avatar" style="width:160px">', previewFileIcon : "<i
	 * class='glyphicon glyphicon-king'></i>", layoutTemplates : { main2 :
	 * '{preview}\n<div class="kv-upload-progress hide"></div>\n{remove}\n{cancel}\n{browse}\n',
	 * actions : '<div class="file-actions">\n' + ' <div
	 * class="file-footer-buttons">\n' + ' {delete} {zoom} {other}' + '
	 * </div>\n' + '</div>', modal : '<div class="modal-dialog modal-lg{rtl}"
	 * role="document">\n' + ' <div class="modal-content">\n' + ' <div
	 * class="modal-header">\n' + ' <div class="kv-zoom-actions
	 * pull-right">{close}</div>\n' + ' <h3 class="modal-title">{heading}
	 * <small><span class="kv-zoom-title"></span></small></h3>\n' + '
	 * </div>\n' + ' <div class="modal-body">\n' + ' <div
	 * class="floating-buttons"></div>\n' + ' <div class="kv-zoom-body
	 * file-zoom-content"></div>\n' + '{prev} {next}\n' + ' </div>\n' + '
	 * </div>\n' + '</div>\n', progress : '', }, });
	 * $("#avatar-1").on("fileuploaded", function(event, data, previewId, index) {
	 * $("#goodDetailForm input[name='goodImage']").val(data.response);
	 * submitInstallIndentGood();
	 * $('#avatar-1').fileinput('reset').fileinput('enable'); });
	 */
	$("input[name='addPrice']").TouchSpin({
		min : 0,
		max : 1000,
		// step : 5,
		boostat : 5,
		maxboostedstep : 10,
		postfix : '元'
	});
	$(".input_accText").TouchSpin({
		min : 0,
		max : 100,
		step : 1,
		boostat : 5,
		maxboostedstep : 10,
	});
	$.post("../territory/selectAvailableProvince", function(data) {
		$("#Province>option").first().nextAll().remove();
		$("#pickupProvince>option").first().nextAll().remove();
		// 这是所有的省份
		$.each(data, function(i, option) {
			$("#Province").append(
					'<option value="' + option.code + '">' + option.province
							+ '</option>');
			$("#pickupProvince").append(
					'<option value="' + option.code + '">' + option.province
							+ '</option>');
		});
	});
	// form_wizad
	$('#stepy_form').stepy({
		backLabel : '上一步',
		nextLabel : '下一步',
		errorImage : true,
		block : true,
		description : true,
		legend : false,
		titleClick : false,
		titleTarget : '#top_tabby',
		validate : true,
		next : function(index) {
			if (fakeIndentID == 0) {
				fakeIndentID = randomChar(22);
			}
		}
	});
	$('#stepy_form').validate({
		rules : {
			'name' : 'required',
			phone : {
				required : true,
				isMobile : true
			},
			province : {
				max : 999998
			},
			city : {
				max : 999998
			},
			country : {
				max : 999998
			},
			'subscribeTime' : {
				required : true,
			},
			'installAddress' : {
				required : true,
				minlength : 5
			}
		},
		errorClass : "validateFontSize error",
		messages : {
			'name' : {
				required : '请输入顾客姓名'
			},
			phone : {
				required : "请输入电话",
				isMobile : "请正确填写您的电话号码"
			},
			province : {
				max : "省未填"
			},
			city : {
				max : "市未填"
			},
			country : {
				max : "区未填"
			},
			subscribeTime : {
				required : "请您填写预约时间",
			},
			installAddress : {
				required : "请填写安装地址！",
				minlength : "详细地址不能小于5个字符！"
			}
		}
	});
}
$("#pickupCity").change(
		function() {
			$("#pickupCountrySelect>option").first().nextAll().remove();
			$.post("../territory/selectAvailableCountry", {
				cityCode : $("#pickupCity").val()
			}, function(data) {
				$.each(data, function(i, option) {
					$("#pickupCountrySelect").append(
							'<option value="' + option.code + '">'
									+ option.country + '</option>');
					$("#pickupCountrySelect>option:nth-child(2)").attr(
							"selected", "selected"); // 给县默认赋值为第一个；
				});
			});
		});
$("#City").change(
		function() {
			$("#countrySelect>option").first().nextAll().remove();
			if (($("#City").val()).indexOf("999999") < 0) {
				$.post("../territory/selectAvailableCountry", {
					cityCode : $("#City").val()
				}, function(data) {
					$.each(data, function(i, option) {
						$("#countrySelect").append(
								'<option value="' + option.code + '">'
										+ option.country + '</option>');
						$("#countrySelect>option:nth-child(2)").attr(
								"selected", "selected"); // 给县默认赋值为第一个；
					});
				});
			}
			loadAccessoryInputTouchSpin($("#Province").val() + "/"
					+ $("#City").val());
		});
$("#Province")
		.change(
				function() {
					$("#City>option").first().nextAll().remove();
					$("#countrySelect>option").first().nextAll().remove();
					if (($("#Province").val()).indexOf("999999") < 0) {
						$
								.post(
										"../territory/selectAvailableCity",
										{
											provinceCode : $(
													"#Province :selected")
													.val()
										},
										function(data) {
											$.each(data, function(i, option) {
												$("#City").append(
														'<option value="'
																+ option.code
																+ '">'
																+ option.city
																+ '</option>');
											});
											$("#City>option:nth-child(2)")
													.attr("selected",
															"selected"); // 给市默认赋值为第一个；
											var city = $("#City :selected")
													.val();
											loadAccessoryInputTouchSpin($(
													"#Province :selected")
													.val()
													+ "/"
													+ $("#City :selected")
															.val());
											$
													.post(
															"../territory/selectAvailableCountry",
															{
																cityCode : city
															},
															function(data) {
																if (data
																		&& data.length > 0) {
																	$
																			.each(
																					data,
																					function(
																							i,
																							option) {
																						$(
																								"#countrySelect")
																								.append(
																										'<option value="'
																												+ option.code
																												+ '">'
																												+ option.country
																												+ '</option>');
																					});
																	$(
																			"#countrySelect>option:nth-child(2)")
																			.attr(
																					"selected",
																					"selected"); // 给县默认赋值为第一个；
																}
															});
										});
					} else {
						loadAccessoryInputTouchSpin($("#Province").val() + "/"
								+ $("#City").val());
					}
				});
$("#pickupProvince").change(
		function() {
			$("#pickupCity>option").first().nextAll().remove();
			$("#pickupCountrySelect>option").first().nextAll().remove();
			$.post("../territory/selectAvailableCity", {
				provinceCode : $("#pickupProvince").val()
			}, function(data) {
				$.each(data, function(i, option) {
					$("#pickupCity").append(
							'<option value="' + option.code + '">'
									+ option.city + '</option>');
				});
				$("#pickupCity>option:nth-child(2)").attr("selected",
						"selected"); // 给市默认赋值为第一个；
				$.post("../territory/selectAvailableCountry", {
					cityCode : $("#pickupCity").val()
				}, function(data) {
					if (data && data.length > 0) {
						$.each(data, function(i, option) {
							$("#pickupCountrySelect").append(
									'<option value="' + option.code + '">'
											+ option.country + '</option>');
						});
						$("#pickupCountrySelect>option:nth-child(2)").attr(
								"selected", "selected"); // 给县默认赋值为第一个；
					}
				});
			});
		});
// 选择帘头的安装情况
function changeHeadSizeInstallSite(object) {
	if ($("input[name='structure']:checked").val() == 0) {
		if ($("input[name='installSite']:checked",
				$("#addClothCurtainClothSizeDIV")).val() == "窗帘盒内安装") {
			if ($(object).val() != "窗帘盒") {
				$("input[name='accessoriesType']", $(object.closest('form')))
						.val('');
				toastr.warning("布尺寸选择了窗帘盒，只能在此选择窗帘盒。");
				$(object).removeAttr("checked");
			} else {
				$("input[name='accessoriesType']", $(object.closest('form')))
						.val('粘带');
			}
		} else {
			if ($(object).val() == "窗帘盒") {
				$("input[name='accessoriesType']", $(object.closest('form')))
						.val('');
				toastr.warning("布尺寸未选择窗帘盒，这里也不能选择窗帘盒。");
				$(object).removeAttr("checked");
			} else {
				if ($(object).val() == "不满墙（无窗帘盒）") {
					$("#headSizeInstallSiteSituation",
							$(object).closest("form")).show();
				} else {
					$("#headSizeInstallSiteSituation",
							$(object).closest("form")).find(
							"input[type='radio']").removeAttr("checked");
					$("#headSizeInstallSiteSituation",
							$(object).closest("form")).hide();
				}
				$("input[name='accessoriesType']", $(object.closest('form')))
						.val('帘头轨');
			}
		}
	} else if ($("input[name='structure']:checked").val() == 1) {
		if ($("input[name='installSite']:checked",
				$("#addClothCurtainYarnSizeDIV")).val() == "窗帘盒内安装") {
			if ($(object).val() != "窗帘盒") {
				$("input[name='accessoriesType']", $(object.closest('form')))
						.val('');
				toastr.warning("纱尺寸选择了窗帘盒，只能在此选择窗帘盒。");
				$(object).removeAttr("checked");
			} else {
				$("input[name='accessoriesType']", $(object.closest('form')))
						.val('粘带');
			}
		} else {
			if ($(object).val() == "窗帘盒") {
				$("input[name='accessoriesType']", $(object.closest('form')))
						.val('');
				toastr.warning("纱尺寸未选择窗帘盒，这里也不能选择窗帘盒。");
				$(object).removeAttr("checked");
			} else {
				if ($(object).val() == "不满墙（无窗帘盒）") {
					$("#headSizeInstallSiteSituation",
							$(object).closest("form")).show();
				} else {
					$("#headSizeInstallSiteSituation",
							$(object).closest("form")).find(
							"input[type='radio']").removeAttr("checked");
					$("#headSizeInstallSiteSituation",
							$(object).closest("form")).hide();
				}
				$("input[name='accessoriesType']", $(object.closest('form')))
						.val('帘头轨');
			}
		}
	} else {
		if ($("input[name='installSite']:checked",
				$("#addClothCurtainClothSizeDIV")).val() == "窗帘盒内安装") {
			if ($(object).val() != "窗帘盒") {
				$("input[name='accessoriesType']", $(object.closest('form')))
						.val('');
				toastr.warning("布尺寸选择了窗帘盒，只能在此选择窗帘盒。");
				$(object).removeAttr("checked");
			} else {
				$("input[name='accessoriesType']", $(object.closest('form')))
						.val('粘带');
			}
		} else {
			if ($(object).val() == "窗帘盒") {
				$("input[name='accessoriesType']", $(object.closest('form')))
						.val('');
				toastr.warning("纱尺寸未选择窗帘盒，这里也不能选择窗帘盒。");
				$(object).removeAttr("checked");
			} else {
				if ($(object).val() == "不满墙（无窗帘盒）") {
					$("#headSizeInstallSiteSituation",
							$(object).closest("form")).show();
				} else {
					$("#headSizeInstallSiteSituation",
							$(object).closest("form")).find(
							"input[type='radio']").removeAttr("checked");
					$("#headSizeInstallSiteSituation",
							$(object).closest("form")).hide();
				}
				$("input[name='accessoriesType']", $(object.closest('form')))
						.val('帘头轨');
			}
		}
	}
}
// 检验添加成品帘的form是否已经填写
function validateAddProductSizeForms() {
	var validateFlag = true;
	$("#addProductCurtainSizeModal  form").each(function(index, oneForm) {
		// if (typeof $("input[name='window']:checked", oneForm)
		// .val() == 'undefined') {
		// validateFlag = false;
		// return validateFlag;
		// }
		// 安装方式
		// if (typeof $("input[name='pinstallSite']:checked",
		// oneForm).val() == 'undefined') {
		// validateFlag = false;
		// return validateFlag;
		// }
		// 安装配件
		// if (typeof $("input[name='accessoriesType']:checked",
		// oneForm).val() == 'undefined') {
		// validateFlag = false;
		// return validateFlag;
		// }
		if ($("input[name='wide']", oneForm).val() == '') {
			validateFlag = false;
			return validateFlag;
		}
		if ($("input[name='high']", oneForm).val() == '') {
			validateFlag = false;
			return validateFlag;
		}
	});
	return validateFlag;
}

// 检验添加布帘的form是否已经填写
function validateAddClothSizeForms() {
	var validateFlag = true;
	$("#addClothCurtainClothSizeModal form").each(
			function(index, oneForm) {
				// if (typeof $("input[name='window']:checked", oneForm)
				// .val() == 'undefined') {
				// validateFlag = false;
				// return validateFlag;
				// }
				// 布帘安装位置
				// if (typeof $("input[name='installSite']:checked",
				// oneForm).val() == 'undefined') {
				// validateFlag = false;
				// return validateFlag;
				// }
				if (typeof $("input[name='accessoriesType']:checked", oneForm)
						.val() == 'undefined') {
					validateFlag = false;
					return validateFlag;
				}
				if (typeof $("input[name='pinstallSite']:checked", oneForm)
						.val() == 'undefined') {
					validateFlag = false;
					return validateFlag;
				}else{
					//选择配件
					if( ! $("#addClothCurtainClothSizeModal #selectPanzhuangfangshi").is(":hidden")){
						if(typeof $("input[name='selectPanzhangpangshi']:checked", oneForm)
						.val() == 'undefined'){
							validateFlag = false;
							return validateFlag;
						}
					}
				}
				// if (typeof $("input[name='production']:checked",
				// oneForm).val() == 'undefined') {
				// validateFlag = false;
				// return validateFlag;
				// }
				if ($("input[name='wide']", oneForm).val() == '') {
					validateFlag = false;
					return validateFlag;
				}
				if ($("input[name='high']", oneForm).val() == '') {
					validateFlag = false;
					return validateFlag;
				}
			});
	return validateFlag;
}
// 检验添加布艺帘纱尺寸的form是否已经填写
function validateAddYarnSizeForms() {
	var validateFlag = true;
	// alert("检验添加布艺帘纱尺寸的form是否已经填写");

	$("#addClothCurtainYarnSizeModal form").each(
			function(index, oneForm) {
				// if (typeof $("input[name='window']:checked", oneForm)
				// .val() == 'undefined') {
				// validateFlag = false;
				// return validateFlag;
				// }
				// if (typeof $("input[name='installSite']:checked",
				// oneForm).val() == 'undefined') {
				// validateFlag = false;
				// return validateFlag;
				// }
				if (typeof $("input[name='accessoriesType']:checked", oneForm)
						.val() == 'undefined') {
					// alert("11111");
					validateFlag = false;
					return validateFlag;
				}
				if (typeof $("input[name='pinstallSite']:checked", oneForm)
						.val() == 'undefined') {
					validateFlag = false;
					return validateFlag;
				}else{
					//选择配件
					if( ! $("#addClothCurtainYarnSizeModal #selectPanzhuangfangshi").is(":hidden")){
						if(typeof $("input[name='selectPanzhangpangshi']:checked", oneForm)
						.val() == 'undefined'){
							validateFlag = false;
							return validateFlag;
						}
					}
				}
				// if (typeof $("input[name='production']:checked",
				// oneForm).val() == 'undefined') {
				// validateFlag = false;
				// return validateFlag;
				// }
				if ($("input[name='wide']", oneForm).val() == '') {
					validateFlag = false;
					return validateFlag;
				}
				if ($("input[name='high']", oneForm).val() == '') {
					validateFlag = false;
					return validateFlag;
				}
			});
	return validateFlag;
}
// 检验添加布艺帘帘头尺寸的form是否已经填写
function validateAddHeadSizeForms() {
	var validateFlag = true;
	$("#addClothCurtainHeadShadeSizeModal form").each(function(index, oneForm) {
		// if (typeof $("input[name='installSite']:checked", oneForm)
		// .val() == 'undefined') {
		// validateFlag = false;
		// return validateFlag;
		// }
		if ($("input[name='wide']", oneForm).val() == '') {
			validateFlag = false;
			return validateFlag;
		}
		if ($("input[name='saleNumber']", oneForm).val() == '') {
			validateFlag = false;
			return validateFlag;
		}
	});
	return validateFlag;
}

/**
 * 
 * @returns
 */
function payInstallIndent(url) {
	$("#payIndentForm").attr("action", url);
	$("#payIndentForm").submit();
}
// 保存一个商品
function submitInstallIndentGood(btn) {
	// 获取商品的基本数据
	var sendData = $('#goodDetailForm').serialize();
	// 获取成品帘尺寸数据
	var addProductCurtainSizeForms = $("#addProductCurtainSizeDIV")
			.find('form');
	// >>>>>>> master

	var finishShade = new Array();
	$.each(addProductCurtainSizeForms, function(i, oneForm) {
		// 这是form表格提交的信息
		var context = $(oneForm).serialize();
		// 信息是否填写完整判断
		if (isProductSizeInput == false && isClothSizeInput == false
				&& isYarnSizeInput == false && isHeadSizeInput == false) {
			toastr.warning("请填写完整信息后再保存！");
			return;
		}
		// /////////////////////////////////////////////////////////////////////////
		context = decodeURIComponent(context, true);
		context = JSON.parse(updateString(context));
		// alert(typeof context)
		if (context.wide && context.high) {
			finishShade.push(context);
		}
		$("#addCurtainModal").modal('hide');
	});

	// if(finishShade.length>0){
	// sendData=sendData+ "&finishShade=" + JSON.stringify(finishShade);
	// }

	// 获取布艺帘布帘尺寸数据
	var addClothCurtainClothSizeForms = $("#addClothCurtainClothSizeDIV").find(
			'form');
	var clothShade = new Array();
	$.each(addClothCurtainClothSizeForms, function(i, oneForm) {
		// 这是form表格提交的信息
		var context = $(oneForm).serialize();
		context = decodeURIComponent(context, true);
		context = JSON.parse(updateString(context));
		clothShade.push(context);
	});
	// if(clothShade.length>0){
	// sendData=sendData+ "&clothShade=" + JSON.stringify(clothShade);
	// }
	//	
	// 获取布艺帘纱帘尺寸数据
	var addClothCurtainYarnSizeForms = $("#addClothCurtainYarnSizeDIV").find(
			'form');
	var yarnShade = new Array();
	$.each(addClothCurtainYarnSizeForms, function(i, oneForm) {
		// 这是form表格提交的信息
		var context = $(oneForm).serialize();
		context = decodeURIComponent(context, true);
		context = JSON.parse(updateString(context));
		yarnShade.push(context);
	});
	// if(yarnShade.length>0){
	// sendData=sendData+ "&yarnShade=" + JSON.stringify(yarnShade);
	// }

	// 获取布艺帘帘头尺寸数据
	var addClothCurtainHeadShadeSizeForms = $(
			"#addClothCurtainHeadShadeSizeDIV").find('form');
	var headShade = new Array();
	$.each(addClothCurtainHeadShadeSizeForms, function(i, oneForm) {
		// 这是form表格提交的信息
		var context = $(oneForm).serialize();
		context = decodeURIComponent(context, true);
		context = JSON.parse(updateString(context));
		headShade.push(context);
	});

	// if(headShade.length>0){
	// sendData=sendData+ "&headShade=" + JSON.stringify(headShade);
	// }
	// <<<<<<< HEAD
	//	
	// closeGoodDetailChooseForm();
	// =======
	// 数据
	// sendData = sendData + "&indentID=" + fakeIndentID;

	// <<<<<<< HEAD
	// $.post("../indent/addFakeGoodsForIndent", sendData, function(data) {
	// alert("sendData"+sendData);
	// refreshIndentGoodTable();
	// });
	// =======
	// $.post("../indent/addFakeGoodsForIndent", sendData, function(data) {
	// refreshIndentGoodTable();
	// });
	// >>>>>>> 48f1b5d2ae21ad40b43ef92336cf4dfc93b699cc
	closeGoodDetailChooseForm();
	if (uploadGoodTypeStatus == 1) {
		sendData = sendData + "&finishShade=" + JSON.stringify(finishShade)
				+ "&indentID=" + fakeIndentID
		$.post("../indent/addFakeGoodsForIndent", sendData, function(data) {
			refreshIndentGoodTable();
		});
	}
	if (uploadGoodTypeStatus == 2) {
		sendData = sendData + "&yarnShade=" + JSON.stringify(yarnShade)
				+ "&indentID=" + fakeIndentID
		$.post("../indent/addFakeGoodsForIndent", sendData, function(data) {
			refreshIndentGoodTable();
		});
	}
	if (uploadGoodTypeStatus == 3) {

		sendData = sendData + "&clothShade=" + JSON.stringify(clothShade)
				+ "&indentID=" + fakeIndentID
		$.post("../indent/addFakeGoodsForIndent", sendData, function(data) {
			refreshIndentGoodTable();
		});
	}
	if (uploadGoodTypeStatus == 4) {
		sendData = sendData + "&yarnShade=" + JSON.stringify(yarnShade)
				+ "&headShade=" + JSON.stringify(headShade) + "&indentID="
				+ fakeIndentID;
		$.post("../indent/addFakeGoodsForIndent", sendData, function(data) {
			refreshIndentGoodTable();
		});
	}
	if (uploadGoodTypeStatus == 5) {
		sendData = sendData + "&clothShade=" + JSON.stringify(clothShade)
				+ "&headShade=" + JSON.stringify(headShade) + "&indentID="
				+ fakeIndentID;
		$.post("../indent/addFakeGoodsForIndent", sendData, function(data) {
			refreshIndentGoodTable();
		});
	}
	if (uploadGoodTypeStatus == 6) {
		sendData = sendData + "&clothShade=" + JSON.stringify(clothShade)
				+ "&headShade=" + JSON.stringify(headShade) + "&indentID="
				+ fakeIndentID;
		$.post("../indent/addFakeGoodsForIndent", sendData, function(data) {
			refreshIndentGoodTable();
		});
	}
	if (uploadGoodTypeStatus == 7) {
		sendData = sendData + "&clothShade=" + JSON.stringify(clothShade)
				+ "&indentID=" + fakeIndentID
		$.post("../indent/addFakeGoodsForIndent", sendData, function(data) {
			refreshIndentGoodTable();
		});
	}
	if (uploadGoodTypeStatus == 8) {
		sendData = sendData + "&clothShade=" + JSON.stringify(clothShade)
				+ "&yarnShade=" + JSON.stringify(yarnShade) + "&headShade="
				+ JSON.stringify(headShade) + "&indentID=" + fakeIndentID;
		$.post("../indent/addFakeGoodsForIndent", sendData, function(data) {
			refreshIndentGoodTable();
		});
	}
	if (uploadGoodTypeStatus == 9) {
		sendData = sendData + "&clothShade=" + JSON.stringify(clothShade)
				+ "&yarnShade=" + JSON.stringify(yarnShade) + "&indentID="
				+ fakeIndentID;
		$.post("../indent/addFakeGoodsForIndent", sendData, function(data) {
			refreshIndentGoodTable();
		});
	}
}

// 关闭付款窗口
function closePayIndentModal() {
	Ewin.confirm({
		message : "生成的订单可以在我的未付款订单中查询和付款"
	}).on(function(e) {
		if (!e) {
			window.location.reload();
			return;
		} else {
			window.location.href = '../indent/installList/pay.htm'
		}
	})
}
// 预览订单的价格
$("#payIndentForm input").change(function() {
	countTotalIndentPrice();
});
// 计算订单的总价格
function countTotalIndentPrice() {
	if (typeof costRules.crampetPrice != "undefined") {
		var totalIndentPrice = new Number(0);
		// 选择数量的价钱
		var crampetNumber = $("#payIndentForm input[name='crampetNumber']")
				.val();
		var fourClawNumber = $("#payIndentForm input[name='fourClawNumber']")
				.val();
		var motorNumber = $("#payIndentForm input[name='motorNumber']").val();
		var accPrice = parseInt(crampetNumber)
				* parseInt(costRules.crampetPrice);
		accPrice = accPrice + parseInt(fourClawNumber)
				* parseInt(costRules.fourClawPrice);
		accPrice = accPrice + parseInt(motorNumber)
				* parseInt(costRules.motorPrice);
		totalIndentPrice = totalIndentPrice + accPrice;
		if ((realIndentPrice + accPrice) > costRules.installStartingFare) {
			totalIndentPrice = realIndentPrice + accPrice;
		} else {
			totalIndentPrice = costRules.installStartingFare;
		}
		if (isNeedTakingGoods == 1) {
			totalIndentPrice = totalIndentPrice
					+ parseInt(costRules.takeGoodsPrice);
		}
		totalIndentPrice = totalIndentPrice
				+ parseInt($("#payIndentForm input[name='addPrice']").val());
		if ($("#payIndentForm input[name='relievedBao']:checked").val() == 1) {
			totalIndentPrice = totalIndentPrice + 5;
		}
		$("#payIndentForm #totalPrice").val(totalIndentPrice);
	}
}
// 计算订单的价格
function countIndentPrice(realIndentPrice) {
	var _indentPrice = new Number(0);
	_indentPrice = parseInt(costRules.installStartingFare);
	if (realIndentPrice > costRules.installStartingFare) {
		_indentPrice = realIndentPrice;
	}
	if ($("input[name='isNeedTakeGoods']:checked").val() == 1) {
		_indentPrice = _indentPrice + parseInt(costRules.takeGoodsPrice);
		isNeedTakingGoods = 1
	} else {
		isNeedTakingGoods = 0;
	}
	indentPrice = _indentPrice;
	$("#payIndentForm #totalPrice").val(indentPrice + 5);
}
// 同步杆长
function syncSaleNumberInput(object) {
	$("input[name='saleNumber']", $(object).closest("form")).val(
			$(object).val());
}

function replaceLikeVal(comp) {
	var textValue = filterStr(comp.value);
	if (textValue.indexOf("'") != -1 || textValue.indexOf("\"") != -1) {
		comp.value = textValue.replace(/\'/g, "").replace(/\"/g, "");
	}
}

function filterStr(str) {
	var pattern = new RegExp(
			"[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？%+_]");
	var specialStr = "";
	for (var i = 0; i < str.length; i++) {
		specialStr += str.substr(i, 1).replace(pattern, '');
	}
	return specialStr;
}